<?php
	namespace Common\Logic;
	use Common\Model\QuestionListModel;
	class QuestionListLogic extends QuestionListModel{
		/*
		* Function:		getQuestionListList
		* Description:	问题明细列表列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getQuestionListList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getQuestionListFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getQuestionListFilter
		* Description:	问题明细列表列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getQuestionListFilter($filter = ''){
			$conditon = array();
			if(!empty($filter['name'])){
				$conditon['name'] = array('like','%'.$filter['name'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getQuestionListCount
		* Description:	问题明细列表列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getQuestionListCount($filter = ''){
			$conditon = $this->getQuestionListFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addQuestionList
		* Description:	增加问题明细列表
		* @param:		$data array 增加的数组
		*/
		public function addQuestionList($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getQuestionListInfo
		* Description:	获取问题明细列表信息 by row
		* @param:		$id int ID
		*/
		public function getQuestionListInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateQuestionList
		* Description:	更新问题明细列表
		* @param:		$data array 更新的数组
		*/
		public function updateQuestionList($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteQuestionList
		* Description:	删除问题明细列表
		* @param:		$id int ID
		*/
		public function deleteQuestionList($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getQuestionListAllList
		* Description:	问题明细列表
		*/
		public function getQuestionListAllList(){
			return $this->where(array('status'=>1))->select();
		}
	}
?>